#include "Item.hh"
#include "ICharacter.hh"
#include "Character.hh"

Item::Item(const std::string& name, const std::string& description, int healthBoost, int attackBoost, int defenseBoost)
    : name(name), description(description), healthBoost(healthBoost), attackBoost(attackBoost), defenseBoost(defenseBoost) {}

Item::~Item() { // Destructor logic if needed
    // Destructor logic if needed
}

Item::Item(const Item& other) {
    name = other.name;
    description = other.description;
    healthBoost = other.healthBoost;
    attackBoost = other.attackBoost;
    defenseBoost = other.defenseBoost;
}
Item& Item::operator=(const Item& other) {
    if (this != &other) {
        name = other.name;
        description = other.description;
        healthBoost = other.healthBoost;
        attackBoost = other.attackBoost;
        defenseBoost = other.defenseBoost;
    }
    return *this;
}

std::string Item::getName() const {
    return name;
}

std::string Item::getDescription() const {
    return description;
}

void Item::applyEffect(ICharacter& character) const {
    character.addHealth(healthBoost);
    character.addAttack(attackBoost);
    character.addDefense(defenseBoost);
    character.setMaxHealth(character.getMaxHealth() + healthBoost);
}

Item* Item::generateRandomItem() {
    srand(time(0));
    std::string names[] = {"Magic Amulet", "Wooden Shield", "Rusty Sword", "Leather Armor"};
    std::string descriptions[] = {"+50 Health", "+10 Defense", "+30 Attack", "+5 Defense"};
    int healthBoosts[] = {50, 0, 0, 0};
    int attackBoosts[] = {0, 0, 30, 0};
    int defenseBoosts[] = {0, 10, 0, 5};

    int index = rand() % 4;
    return new Item(names[index], descriptions[index], healthBoosts[index], attackBoosts[index], defenseBoosts[index]);
}